<?php
namespace command;

use thinkless\common\BaseCommand;
use PHPUnit\TextUI\Command;
use PHPUnit\Util\Blacklist;
use think\facade\Session;

/**
 * 运行所有测试:`php think test`
 * 框架.类:`php think test --filter [Class]`
 * 框架.类.方法:`php think test --filter [Class]::[Function]`
 */
class Test extends BaseCommand
{
    /**
     * 配置指令
     */
    public function configure() {
        $this->setName('test')
            ->setDescription('单元测试')
            ->ignoreValidationErrors();
    }

    /**
     */
    public function start() {
        Session::init();
        $argv = $_SERVER['argv'];
        array_shift($argv); // think
        array_shift($argv); // test
        array_unshift($argv, 'phpunit');
        Blacklist::$blacklistedClassNames = [];
        $code = (new Command())->run($argv, false);
        return $code;
    }

}
